<?php
	function f250($sql){
		//data handle instance
		//set request
		//define format
		//set format
		//define query string
		//process time
		//process fitler
		$dataHandle = new DataHandle();
		$dataHandle->setRequest("250");

		$action = getValue($_GET['action']);

		if ($action == "getItems"){
			$format = array(
				"product_id" => "numb6",
			);

			$query = getQuery();
			$dataHandle->setFormat($format);
			print($dataHandle->printJSON($sql, $query));
		}
		else{
			$temp = array();
			$temp['error'] = "250: Bad request";
			print(json_encode($temp));
		}

		unset($dataHandle);

	}

	function getQuery(){
		$queryString = "
			select
				product_id as ID,
				product_id,
				description,
				line_id,
				weight_per_unit,
				pouches_per_unit
			from lin_products
			where active = 1";


		$oderByFiled = getValue($_GET['sortItem']);
		$oderByValue = getValue($_GET['ascDesc']);

		if($oderByFiled !== "" and $oderByValue !== "")
			$queryString = $queryString." order by ".$oderByFiled." ".$oderByValue;
		
		return $queryString;
	}
?>